<template>
  <div>
    <NavBar></NavBar>
    <div class="menu">
      <div class="menu-title"><i class="el-icon-position">地产列表</i></div>
      <!-- 设置路由挂载点 -->
      <router-view></router-view>
      <div class="content">
        <router-link
          class="menu-content"
          v-for="item in list"
          :key="item.id"
          :to="`/estate/particulars?id=${item.id}`"
        >
          <div class="left">
            <img :src="item.image" alt="" />
          </div>
          <div class="right">
            <h5>{{ item.title }}</h5>
            <div class="right-content">
              {{ item.desc }}
            </div>
          </div>
        </router-link>
      </div>
      <div class="noList" v-if="list.length === 0"></div>
    </div>
    <Footer v-if="list.length"></Footer>
  </div>
</template>

<script>
import { getAgentList } from "@/api/agent";
export default {
  data() {
    return {
      list: [],
    };
  },
  async created() {
    this.list = await getAgentList({
      category: this.$route.query.id,
    });
    console.log("筛选列表", this.list);
  },
};
</script>

<style lang="less" scoped>
.menu {
  // padding-bottom: 200px;
  width: 1000px;
  margin: 20px auto;
  // background-color: #fff;
}
.menu-title {
  // line-height: 700;
  font-size: 20px;
  // background-color: #fff;
  padding: 6px 0;
  color: orange;
}
.content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.menu-content {
  background-color: #fff;
  margin: 10px;
  height: 400px;
  width: 31.3%;
  text-align: center;
  border-radius: 20px;
  // border: 1px solid #ccc;
  &:hover {
    box-shadow: 3px 2px 5px 2px #ccc;
  }
  .left {
    padding: 2px;
    height: 280px;
    overflow: hidden;
    img {
      width: 95%;
      height: 280px;
      object-fit: cover;
      padding: 5px 10px;
    }
  }
  .right {
    flex: 1;
    padding: 5px 10px;
    h5 {
      text-align: center;
      font-weight: 700;
      line-height: 30px;
    }
    .right-content {
      line-height: 20px;
    }
  }
  .noList {
    background-color: pink;
    height: 200px;
    width: 800px;
  }
}
</style>